<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Data-Table 表格</title>
    <link rel="stylesheet" href="../../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../../frame/static/css/style.css">
    <link rel="stylesheet" href="../../css/common.css">
    <link rel="stylesheet" href="../../css/set/banner.css">
    <link rel="icon" href="../../frame/static/image/code.png">
</head>
<body class="body">
<!-- 工具集 -->
<div class="my-btn-box">
    <span class="fl">
        <a class="layui-btn btn-add btn-default" id="btn-refresh" onclick="location.reload()"><i class="layui-icon">&#x1002;</i></a>
        <a class="layui-btn btn-add btn-default" id="btn-add" >添加</a>
    </span>
</div>

<!-- 表格 -->
<div class="layui-row layui-col-space30">

</div>
<script src="../../js/public/jquery-3.1.1.min.js"></script>
<script src="../../js/layer/layer.js"></script>
<script src="../../js/public/common.js"></script>
<script>
  $(function(){
        List();

        $('#btn-add').click(function(){
            layOpen('添加','1000px','800px','badd.html');
        });
        $('.edit').click(function(){
            let ids = $(this).attr('ids');
            layOpen('编辑','1000px','800px','bedit.html?id='+ids)
        });
        $('.info').click(function(){
            let ids = $(this).attr('ids');
            layFirm('删除','admin/BannerDel',{id:ids})
        })
    });

    function List(){
        let data = AjaxForm('admin/BannerList');
        let html = '';
        if(JSON.stringify(data.data) !== '[]'){
            for (let i=0;i<data.length;i++){
                let show = ``;
                if(data[i].show == 1){
                    show = `<p class="info show" ids="${data[i].id}">删除</p>`
                }else{
                    show = `<p class="info shownot" ids="${data[i].id}">删除</p>`
                }
                html += `
            <div class="layui-col-sm4">
                <div class="cmdlist-container">
                    <a href="javascript:;" >
                        <img src="${data[i].banner}" ids="${data[i].id}" class="edit">
                        <div class="cmdlist-text">${show}</div>
                    </a>
                </div>
            </div>
           `;
            }
        }else{
            html = `<p style="text-align: center">没有更多数据了</p>`
        }
        $('.layui-row').html(html);
    }
  
</script>

</body>
</html>